package com.ruoyi.business.service.impl;

import java.util.List;

import com.ruoyi.business.domain.vo.SimpleCollectedDataVO;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.CollectedDataMapper;
import com.ruoyi.business.domain.CollectedData;
import com.ruoyi.business.service.ICollectedDataService;

/**
 * 采集数据Service业务层处理
 * 
 * @author asher
 * @date 2021-12-12
 */
@Service
public class CollectedDataServiceImpl implements ICollectedDataService 
{
    @Autowired
    private CollectedDataMapper collectedDataMapper;

    @Autowired
    private RedisCache redisCache;

    /**
     * 查询采集数据
     * 
     * @param cardId 采集数据主键
     * @return 采集数据
     */
    @Override
    public CollectedData selectCollectedDataByCardId(String cardId)
    {
        return collectedDataMapper.selectCollectedDataByCardId(cardId);
    }

    /**
     * 查询采集数据列表
     * 
     * @param collectedData 采集数据
     * @return 采集数据
     */
    @Override
    public List<CollectedData> selectCollectedDataList(CollectedData collectedData)
    {
        return collectedDataMapper.selectCollectedDataList(collectedData);
    }

    /**
     * 新增采集数据
     * 
     * @param collectedData 采集数据
     * @return 结果
     */
    @Override
    public int insertCollectedData(CollectedData collectedData)
    {
//        collectedData.setCreateTime(DateUtils.getNowDate().getTime());
        return collectedDataMapper.insertCollectedData(collectedData);
    }

    /**
     * 修改采集数据
     * 
     * @param collectedData 采集数据
     * @return 结果
     */
    @Override
    public int updateCollectedData(CollectedData collectedData)
    {
        return collectedDataMapper.updateCollectedData(collectedData);
    }

    /**
     * 批量删除采集数据
     * 
     * @param cardIds 需要删除的采集数据主键
     * @return 结果
     */
    @Override
    public int deleteCollectedDataByCardIds(String[] cardIds)
    {
        return collectedDataMapper.deleteCollectedDataByCardIds(cardIds);
    }

    /**
     * 删除采集数据信息
     * 
     * @param cardId 采集数据主键
     * @return 结果
     */
    @Override
    public int deleteCollectedDataByCardId(String cardId)
    {
        return collectedDataMapper.deleteCollectedDataByCardId(cardId);
    }

    @Override
    public int insertCollectedDataBatch(List<CollectedData> list) {
        redisCache.setCacheObject("INSERT_DB_STATUS", true);
        return collectedDataMapper.insertCollectedDataBatch(list);
    }

    @Override
    public List<SimpleCollectedDataVO> selectCollectDataByCollectItemId(Long collectItemId, Integer size) {
        return collectedDataMapper.selectCollectDataByCollectItemId(collectItemId, size);
    }
}
